<template>
<div>
  <input type="file" @change="upload" value="文件">
</div>
</template>

<script>
  export default {
    name: "testFile",
    methods:{
      upload(e){
        let fi = e.target.files[0];
        let formdata = new FormData();
        formdata.append('file' , fi);
        // file({
        //   url : 'https://test.zlbzb.cn/api/v1/uploadTaskFile',
        //   data: formdata ,
        //   headers:{
        //     'Authorization':'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvdGVzdC56bGJ6Yi5jblwvYXBpXC92MVwvdXNlclwvbG9naW4iLCJpYXQiOjE2MDQyOTk5NTUsImV4cCI6MTYwNjcxOTE1NSwibmJmIjoxNjA0Mjk5OTU1LCJqdGkiOiJNUk8wR1RUalRqb0dFcmJXIiwic3ViIjo0OTUsInBydiI6IjRkZGFlNTczZWFkYjc5Y2RlYTcyYzYyMmYyYjgwMDgzODhjNDExOTIifQ.nIm4MURMnC1QhykeWLYmcfN1kRy2PfZy2uAskkLVnVo' ,
        //     // 'Content-Type':'multipart/form-data'
        //   } ,
        //   // noBrw : 2 ,
        // })

        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
          if (xhr.readyState === 4 && xhr.status === 200) {
            console.log(xhr.responseText);
            info.innerHTML = xhr.responseText;
          }
        };
        xhr.open("POST", "https://test.zlbzb.cn/api/v1/uploadTaskFile");
        xhr.setRequestHeader(       'Authorization',"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvdGVzdC56bGJ6Yi5jblwvYXBpXC92MVwvdXNlclwvbG9naW4iLCJpYXQiOjE2MDQyOTk5NTUsImV4cCI6MTYwNjcxOTE1NSwibmJmIjoxNjA0Mjk5OTU1LCJqdGkiOiJNUk8wR1RUalRqb0dFcmJXIiwic3ViIjo0OTUsInBydiI6IjRkZGFlNTczZWFkYjc5Y2RlYTcyYzYyMmYyYjgwMDgzODhjNDExOTIifQ.nIm4MURMnC1QhykeWLYmcfN1kRy2PfZy2uAskkLVnVo" ,)
        // xhr.setRequestHeader('Content-Type','multipart/form-data');
        xhr.send(formdata);
      }
    }
  }
</script>

<style scoped>

</style>
